package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import com.financing.wap.common.CommonConstantUtil.CommonStatus;
import com.financing.wap.dao.IDstVirtualGoodsDao;
import com.financing.wap.dto.DstVirtualGoodsDTO;
import com.financing.wap.service.IDstVirtualGoodsService;
import com.financing.wap.util.DTOdateSetUtil;
/**
 * dst_virtual_goods  
 * 虚拟商品表 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Service("dstVirtualGoodsService")
public class DstVirtualGoodsServiceImpl implements IDstVirtualGoodsService{

	@Autowired
	private IDstVirtualGoodsDao dstVirtualGoodsDao;

	@Override
	public int insert(DstVirtualGoodsDTO dstVirtualGoods) throws SQLException {
		DTOdateSetUtil.setCreateInfo(dstVirtualGoods);
		DTOdateSetUtil.setUpdateInfo(dstVirtualGoods);
		dstVirtualGoods.setDeleteTag(CommonStatus.DELETE_TAG_NORMAL);
		return dstVirtualGoodsDao.insert(dstVirtualGoods);
	}

	@Override
	public void update(DstVirtualGoodsDTO dstVirtualGoods) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstVirtualGoods);
		dstVirtualGoodsDao.update(dstVirtualGoods);
	}

	@Override
	public void updateForce(DstVirtualGoodsDTO dstVirtualGoods) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstVirtualGoods);
		dstVirtualGoodsDao.updateForce(dstVirtualGoods);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		dstVirtualGoodsDao.delete(id);
	}
	
	@Override
	public List<DstVirtualGoodsDTO> queryList(DstVirtualGoodsDTO dstVirtualGoods) throws SQLException {
		return dstVirtualGoodsDao.queryList(dstVirtualGoods);
	}

	@Override
	public int queryListCount(DstVirtualGoodsDTO dstVirtualGoods) throws SQLException {
		return dstVirtualGoodsDao.queryListCount(dstVirtualGoods);
	}

	@Override
	public DstVirtualGoodsDTO loadById(Integer id) throws SQLException {
		return dstVirtualGoodsDao.loadById(id);
	}
 	@Override
	public DstVirtualGoodsDTO queryListGetFirst(DstVirtualGoodsDTO dstVirtualGoods)
			throws SQLException {
		 List<DstVirtualGoodsDTO> queryList = queryList(dstVirtualGoods);
		 if(queryList==null||queryList.size()==0){
			 return new DstVirtualGoodsDTO();
		 }
		 return queryList.get(0);
	}
}
